package com.filldream.fastboot.common.entity.db;

import com.filldream.fastboot.common.okutil.cls.dto.ClsNewsSimpleItem;
import com.filldream.fastboot.common.util.JsonUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import org.apache.commons.lang3.StringUtils;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

/**
 * 东财资讯
 */
@Data
@Accessors(chain = true)
public class CfArticle {

    @TableId(value = "post_id", type = IdType.NONE)
    private Long postId;

    @ApiModelProperty(value = "资讯标题")
    private String postTitle;

    @ApiModelProperty(value = "资讯代码")
    private String stockbarCode;

    @ApiModelProperty(value = "发布时间")
    private Date postPublishTime;

    @ApiModelProperty(value = "资讯作者")
    private String userNickname;

    @ApiModelProperty(value = "机器人接收者")
    private String sendOwner;

    public List<String> getSendOwnerList() {
        if(StringUtils.isBlank(sendOwner)){
            return new LinkedList<>();
        }
        return JsonUtil.fromJosnArray(  sendOwner, String.class);
    }

    public ClsNewsSimpleItem toClsNewsSimpleItem(){
        ClsNewsSimpleItem item = new ClsNewsSimpleItem();
        item.setTitle(  postTitle );
        item.setIsTop(true);
        item.setLinkUrl("https://guba.eastmoney.com/news,"+stockbarCode+","+postId+".html");
        return item;
    }

}
